﻿# encoding:utf-8
# 测试 wxpyDbUser
from wxpyImport import *
from db.wxpyDbUser import *
import wxpy


def testDbAddOrUpdateUserAll(user):
    try:
        dbd = dbData()
        result = dbAddOrUpdateUserAll(dbd, user)
        logInfo('result: '+str(result))
    except Exception as e:
        traceback.print_exc()
        logError('testExeSql------------------err: '+str(e))
    finally:
        closeDb(dbd)

def testDbUserReplaceEmojiDict():
    strJson = """
    {
        "Uin":0,
        "UserName":"@d196c4d0dbbad57663541d2d5eed4c190ea741ac3ff044d463d22eb4b4a4f6ce",
        "NickName":"Yang",
        "AttrStatus":102821,
        "PYInitial":"YANG",
        "PYQuanPin":"Yang",
        "RemarkPYInitial":"",
        "RemarkPYQuanPin":"",
        "MemberStatus":0,
        "DisplayName":"",
        "KeyWord":"",
        "HeadImgUrl":"/cgi-bin/mmwebwx-bin/webwxgeticon?seq=0&username=@d196c4d0dbbad57663541d2d5eed4c190ea741ac3ff044d463d22eb4b4a4f6ce&chatroomid=@2af5664396c6dd60e23977ebd33d3038&skey=",
        "ContactFlag":0,
        "MemberCount":0,
        "RemarkName":"",
        "HideInputBarFlag":0,
        "Sex":1,
        "Signature":"。",
        "VerifyFlag":0,
        "OwnerUin":0,
        "StarFriend":0,
        "AppAccountFlag":0,
        "Statues":0,
        "Province":"广东",
        "City":"佛山",
        "Alias":"",
        "SnsFlag":17,
        "UniFriend":0,
        "ChatRoomId":0,
        "EncryChatRoomId":"@2af5664396c6dd60e23977ebd33d3038",
        "IsOwner":0,
        "is_group":0,
        "puid":"b4a4f6ce"
    }
    """
    try:
        dict = json.loads(strJson)
        dict['Signature'] = r'<span class="emoji emoji1f4a9"></span><span class="emoji emoji1f4a9"></span>在屎壳郎的国度里，卖大粪才能成功<span class="emoji emoji1f4a9"></span><span class="emoji emoji1f4a9"></span><span class="emoji emoji1f4a9"></span><span class="emoji emoji1f4a9"></span><span class="emoji emoji1f4a9"></span><span class="emoji emoji1f4a9"></span><span class="emoji emoji1f4a9"></span>'
        # 自己增加的
        print(dbUserReplaceEmojiDict(dict))
    except Exception as e:
        traceback.print_exc()
        logError('testDbUserReplaceEmojiDic------------------err: '+str(e))
